package com.tjdx.projectsubmission.controller;
import com.tjdx.projectsubmission.service.EventRecordService;
import com.tjdx.projectsubmission.vo.EventSubReqVo;
import com.tjdx.projectsubmission.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/event")
@CrossOrigin
public class EventController {
    @Autowired
    private EventRecordService eventRecordService;

    /**
     * 事件填报页接口
     * @param roleId 角色id
     * @param quarterId 时间id
     * @return
     */
    @GetMapping("/from/{roleId}/{quarterId}")
/*    @GetMapping("/from/{roleId}/{quarterId}/{operate}")*/
    public R from(@PathVariable(value = "roleId") Integer roleId,@PathVariable("quarterId") String quarterId
           /* ,@PathVariable("operate") String operate*/) {
        return eventRecordService.fromEventRecordInfo(roleId,quarterId,null);
    }

    /**
     * 事件填报页提交接口
     * @param eventSubReqVo 填报数据
     * @return
     */
    @PostMapping("/from/submit")
    public R submit(@RequestBody EventSubReqVo eventSubReqVo) {
        return eventRecordService.submitEventRecordInfo(eventSubReqVo);
    }


    /**
     * 事件汇总列表接口
     * @param  quarterId 时间id
     * @return
     */
    @GetMapping("/list")
    public R list(String quarterId) {
        return eventRecordService.eventRecordList(quarterId);
    }

    /**
     * 事件记录数值修改
     *
     * @param id     事件记录id
     * @param number 数值
     * @return
     */
    @GetMapping("/updateNumber/{id}/{number}")
    public R updateNumber(@PathVariable(value = "id") Integer id, @PathVariable(value = "number") String number) {
        return eventRecordService.updateNumber(id, number);
    }
}
